import { reactive } from 'vue'
interface IState {
  pack_status: number
  status: number
  fieldStatus: number
  platform?: string //系统信息
  node_name?: string //节点名称
  tcc_version?: string //tcc包版本
  kernel_version?: string //内核版本
  offset: number
  limit: number
}
export const state = reactive<IState>({
  pack_status: 0,
  status: 0,
  fieldStatus: 1,
  node_name: '',
  platform: '',
  kernel_version: '',
  tcc_version: '',
  offset: 0,
  limit: 20
})
export const PACK_STATUS: Record<number, any> = {
  0: '全部',
  1: '待打包(预留)',
  2: '打包中',
  3: '打包成功',
  4: '打包失败'
}
export const PACK_STATUS_LIST = [
  { value: 0, label: '全部打包状态' },
  { value: 1, label: '待打包(预留)' },
  { value: 2, label: '打包中' },
  { value: 3, label: '打包成功' },
  { value: 4, label: '打包失败' }
]
export const USE_STATUS: Record<number, any> = {
  1: '已有包',
  2: '无'
}
// export const USE_STATUS_LIST: Record<number, any> = [
//   { value: 0, label: '全部可用状态' },
//   { value: 1, label: '已有包' },
//   { value: 2, label: '无' }
// ]
export const STATUS_STYLE: Record<number, any> = {
  3: '#28B06F',
  4: '#EA2C2C'
}
export const OPERATION_LIST = [
  {
    value: 1,
    label: '打包版本'
  },
  {
    value: 2,
    label: '节点名称'
  },
  {
    value: 3,
    label: '系统信息'
  },
  {
    value: 4,
    label: '内核信息'
  }
]
export const OPERATION_DATA: Record<number, any> = {
  1: 'tcc_version',
  2: 'node_name',
  3: 'platform',
  4: 'kernel_version'
}
export const resetFunc = () => {
  const keys = Object.keys(state) as (keyof Pick<
    IState,
    'node_name' | 'platform' | 'kernel_version' | 'tcc_version'
  >)[]
  for (const key of keys) {
    state[key] = ''
    state.fieldStatus = 1
    state.pack_status = 0
  }
}
